#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    int T; cin >> T;
    while(T--){
        map<pii, int> id;
        pii ans; int mini = INT_MAX;
        int N; cin >> N;
        string s; cin >> s;
        
        pii p = make_pair(0, 0);
        id[p] = 0;
        for (int i = 0; i < N; ++i) {
            int j = i+1;
            switch (s[i]){
                case 'U':{++p.second; break;}
                case 'D':{--p.second; break;}
                case 'L':{++p.first; break;}
                case 'R':{--p.first; break;}
            }
            if(id.count(p)){
                int l = id[p]+1, r = j;
                if(r - l + 1 < mini){
                    mini = r - l + 1;
                    ans.first = l, ans.second = r;
                }
            }
            id[p] = j;
        }
        if(mini < INT_MAX) cout << ans.first << " " << ans.second << "\n";
        else cout << -1 << "\n";
    }
    return 0;
}